package com.codeZ.FactoryPattern.simpleFactory.factory;

import com.codeZ.FactoryPattern.simpleFactory.service.IFreeGoods;
import com.codeZ.FactoryPattern.simpleFactory.service.impl.DiscountFreeGoodsService;
import com.codeZ.FactoryPattern.simpleFactory.service.impl.SmallGiftFreeGoodsService;
import com.codeZ.FactoryPattern.simpleFactory.service.impl.YouKuMemberFreeGoodsService;

/**
 * 具体的工厂类
 *
 * @author codeZhang
 * @Date 2024/7/31 17:53
 */
public class FreeGoodsFactory {

    public static IFreeGoods getFreeGoods(Integer awardTypes) {
        if (awardTypes == 1) {
            return new DiscountFreeGoodsService();
        } else if (awardTypes == 2) {
            return new SmallGiftFreeGoodsService();
        } else if (awardTypes == 3) {
            return new YouKuMemberFreeGoodsService();
        }else {
            throw new RuntimeException("没有该类型的奖品");
        }
    }

}
